var c = 0;

function next() {
  if (c < 2) {
    c++;
    left = c * -240;
    left = left + "px";
    $("#ul-icon").animate({
      left: left,
    });
  }
}

function prev() {
  if (c > 0) {
    c--;
    left = c * -240;
    left = left + "px";
    $("#ul-icon").animate({
      left: left,
    });
  }
}

$(function () {
  $(".left-li2").mouseover(function () {
    $(".drop-down").show();
    $(".left-div1").css({
      "background-color": "#FFFFFF",
      border: "1px solid #E6E6E6",
      "border-bottom": "none",
    });
    $(".left-div1 a").css({
      color: "#E3101E",
    });
  });
  $(".left-li2").mouseout(function () {
    $(".drop-down").hide();
    $(".left-div1").css({
      "background-color": "transparent",
      border: "1px solid transparent",
      "border-bottom": "none",
    });
    $(".left-div1 a").css({
      color: "#5E5E5E",
    });
  });

  $(".right-li2").mouseover(function () {
    $(".right-dropdown").show();
    $(".right-div1").css({
      "background-color": "#FFFFFF",
      border: "1px solid #E6E6E6",
      "border-bottom": "none",
    });
    $(".right-div1 a").css({
      color: "#E3101E",
    });
  });
  $(".right-li2").mouseout(function () {
    $(".right-dropdown").hide();
    $(".right-div1").css({
      "background-color": "transparent",
      border: "1px solid transparent",
      "border-bottom": "none",
    });
    $(".right-div1 a").css({
      color: "#5E5E5E",
    });
  });

  $(".service").mouseover(function () {
    $(".s-dropdown").show();
    $(".s-div").css({
      "background-color": "#FFFFFF",
      border: "1px solid #E6E6E6",
      "border-bottom": "none",
    });
    $(".s-div a").css({
      color: "#E3101E",
    });
  });
  $(".service").mouseout(function () {
    $(".s-dropdown").hide();
    $(".s-div").css({
      "background-color": "transparent",
      border: "1px solid transparent",
      "border-bottom": "none",
    });
    $(".s-div a").css({
      color: "#5E5E5E",
    });
  });

  $(".nav").mouseover(function () {
    $(".n-dropdown").show();
    $(".n-div").css({
      "background-color": "#FFFFFF",
      border: "1px solid #E6E6E6",
      "border-bottom": "none",
    });
    $(".n-div").css({
      color: "#E3101E",
    });
  });
  $(".nav").mouseout(function () {
    $(".n-dropdown").hide();
    $(".n-div").css({
      "background-color": "transparent",
      border: "1px solid transparent",
      "border-bottom": "none",
    });
    $(".n-div").css({
      color: "#5E5E5E",
    });
  });

  $(".phone").mouseover(function () {
    $(".p-dropdown").show();
    $(".ph-div").css({
      "background-color": "#FFFFFF",
      border: "1px solid #E6E6E6",
      "border-bottom": "none",
    });
    $(".ph-div a").css({
      color: "#E3101E",
    });
  });
  $(".phone").mouseout(function () {
    $(".p-dropdown").hide();
    $(".ph-div").css({
      "background-color": "transparent",
      border: "1px solid transparent",
      "border-bottom": "none",
    });
    $(".ph-div a").css({
      color: "#5E5E5E",
    });
  });


  //focus
  $(".nav-o li").each(function (e) {
    var n = parseInt(e) + 1;
    var _this = $(this);
    $(this).mouseover(function () {
      $(".banner" + n)
        .fadeIn()
        .siblings()
        .hide();
      _this.find("a").css({
        "background-color": "red",
        opacity: "1",
      });
    });
    $(this).mouseout(function () {
      _this.find("a").css({
        "background-color": "#000",
        opacity: ".3",
      });
    });
  });
  //focus

  //op
  $(".op").each(function (e) {
    var _this = $(this);
    $(this).mouseover(function () {
      _this.stop().animate(
        {
          opacity: "0.8",
        },
        500,
        function () {
          _this.stop().animate(
            {
              opacity: "1",
            },
            500
          );
        }
      );
    });
  });
  //op

  //slider
  $(".no li").each(function (e) {
    var n = parseInt(e) + 1;
    var _this = $(this);
    $(this).mouseover(function () {
      $(".slider" + n)
        .fadeIn()
        .siblings()
        .hide();
      _this.find("a").css({
        "background-color": "red",
        opacity: "1",
      });
    });
    $(this).mouseout(function () {
      _this.find("a").css({
        "background-color": "#fff",
        opacity: ".6",
      });
    });
  });

  /*var nowpage = 1;
	var time;
	time = setInterval(run, 1000);
	
	$(".focus-box").mouseover(function() {
		clearInterval(time);
		$(".pre").show();
		$(".next").show();
	});
	$(".focus-box").mouseout(function() {
		time = setInterval(run, 1000);
		$(".pre").hide();
		$(".next").hide();
	});
	
	function run(){
		if(nowpage == 6){
			nowpage = 1;
		}
		$(".focus-box li").eq(nowpage - 1).stop().show().siblings('li').stop().hide();
		
		$(".no li").eq(nowpage - 1).find("a").css({
				"background-color":"red",
				"opacity": "1",
			}).siblings('li').css({
				"background-color":"#fff",
				"opacity": ".6",
			});
			
		$(".nav-o li a").eq(nowpage - 1).css({
				"background-color":"red",
				"opacity": "1",
			}).parent('li').siblings().find('a').css({
				"background-color":"#000",
				"opacity": ".6",
			});
		
		nowpage++;
	}*/

  /**************************/
  /*banner*/

  var nowpage = 1;
  var time;

  time = setInterval(run, 2000);

  $(".focus-box").mouseover(function () {
    clearInterval(time);
  });
  $(".nav-o").mouseover(function () {
    clearInterval(time);
  });
  $(".cover1").mouseover(function () {
    clearInterval(time);
  });
  $(".cover2").mouseover(function () {
    clearInterval(time);
  });

  $(".focus-box").mouseout(function () {
    time = setInterval(run, 2000);
  });
  $(".nav-o").mouseout(function () {
    time = setInterval(run, 2000);
  });
  $(".cover1").mouseout(function () {
    time = setInterval(run, 2000);
  });
  $(".cover2").mouseout(function () {
    time = setInterval(run, 2000);
  });

  function run() {
    if (nowpage == 6) {
      nowpage = 1;
    }

    $(".focus-box li")
      .eq(nowpage - 1)
      .stop()
      .show()
      .siblings("li")
      .stop()
      .hide();

    $(".nav-o li")
      .eq(nowpage - 1)
      .find("a")
      .css({
        "background-color": "red",
        opacity: "1",
      })
      .parent("li")
      .siblings(".nav-o li")
      .find("a")
      .css({
        "background-color": "#000",
        opacity: ".3",
      });

    nowpage++;
  }

  $(".nav-o li").mouseover(function () {
    var _this = $(this);
    zz = setTimeout(function () {
      var index = _this.index();
      index++;
      nowpage = index;

      $(".nav-o li a").css({
        "background-color": "#000",
        opacity: ".3",
      });
      _this.find("a").css({
        "background-color": "red",
        opacity: "1",
      });

      $(".focus-box li")
        .eq(nowpage - 1)
        .stop()
        .show()
        .siblings("li")
        .stop()
        .hide();
    }, 300);
  });

  $(".nav-o li").mouseout(function () {
    clearTimeout(zz);
  });

  $(".cover1").click(function () {
    nowpage--;
    if (nowpage == 0) {
      nowpage = 5;
    }

    $(".nav-o li")
      .eq(nowpage - 1)
      .find("a")
      .css({
        "background-color": "red",
        opacity: "1",
      })
      .parent("li")
      .siblings(".nav-o li")
      .find("a")
      .css({
        "background-color": "#000",
        opacity: ".3",
      });

    $(".focus-box li")
      .eq(nowpage - 1)
      .stop()
      .show()
      .siblings("li")
      .stop()
      .hide();
  });

  $(".cover2").click(function () {
    if (nowpage == 6) {
      nowpage = 1;
    }

    $(".nav-o li")
      .eq(nowpage - 1)
      .find("a")
      .css({
        "background-color": "red",
        opacity: "1",
      })
      .parent("li")
      .siblings(".nav-o li")
      .find("a")
      .css({
        "background-color": "#000",
        opacity: ".3",
      });

    $(".focus-box li")
      .eq(nowpage - 1)
      .stop()
      .show()
      .siblings("li")
      .stop()
      .hide();
    nowpage++;
  });

  /*****************************/

  //slider

  //tab
  $(".tab li").each(function (e) {
    var n = parseInt(e) + 1;
    var _this = $(this);
    $(this).mouseover(function () {
      $(".main" + n)
        .fadeIn()
        .siblings()
        .hide();
      _this.addClass("cur").siblings().removeClass("cur");
    });
    $(this).mouseout(function () {});
  });
  //tab

  //ad
  $(".close").click(function () {
    $(".ad-div").slideUp();
  });
  //ad

  //	倒计时

  function GetRTime() {
    var EndTime = new Date("2017/05/31 22:00:00");
    var NowTime = new Date();
    var t = EndTime.getTime() - NowTime.getTime();
    var d = 0;
    var h = 0;
    var m = 0;
    var s = 0;
    if (t >= 0) {
      //    d=Math.floor(t/1000/60/60/24);
      h = Math.floor((t / 1000 / 60 / 60) % 24);
      m = Math.floor((t / 1000 / 60) % 60);
      s = Math.floor((t / 1000) % 60);
    }

    /*document.getElementById("t_d").innerHTML = d + "天";
		document.getElementById("t_h").innerHTML = h + "时";
		document.getElementById("t_m").innerHTML = m + "分";
		document.getElementById("t_s").innerHTML = s + "秒";*/

    $(".num").eq(0).html(h);
    $(".num").eq(1).html(m);
    $(".num").eq(2).html(s);
  }
  setInterval(GetRTime, 0);

  //	倒计时

  //	猜你喜欢
  var guessPage = 1;
  $(".nex").click(function () {
    if (guessPage == 4) {
      guessPage = 1;
    }
    $(".ul").hide();
    $(".ul" + guessPage).show();
    guessPage++;
  });
  $(".prev").click(function () {
    if (guessPage == 0) {
      guessPage = 3;
    }
    $(".ul").hide();
    $(".ul" + guessPage).show();
    guessPage--;
  });

  //	猜你喜欢
});
